package com.ding.unsafe;

import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author ding
 * @date 2021/7/17 20:52
 */


public class MapTest {

    public static void main(String[] args) {
        //HashMap<String, String> map = new HashMap<String,String >(16,0.75);
        //map是这样用的吗？ 不是，工作中不用hashMap
        // 默认等价于什么？
//        HashMap<String, String> map = new HashMap<String,String >();
        ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
        //加载因子、初始化容量

        for (int i = 0; i < 30; i++) {
            new Thread(
                    ()->{
                        map.put(Thread.currentThread().getName(), UUID.randomUUID().toString().substring(0, 5));
                        System.out.println("map = " + map);
                    }
            ).start();
        }
    }
}
